<?php
defined('_JEXEC') or die('Restricted access');
class braincodeSmoothGallery{

	function createSlideshow($slides,$sw,$sh,$sp){
	$html='';
	$delay=intval($sp)*1000;
	if(!empty($slides)&&is_array($slides)){
	jimport('joomla.filesystem.file');
	$document=&JFactory::getDocument();
	$document->addStyleDeclaration('
		#myGallerySet{
		
			width: '.intval($sw).'px;
			height: '.intval($sh).'px;
			z-index:5;
			overflow:hidden;
			clear:both;
			margin:0 auto;
			
	
		}

		');
	$document->addStyleSheet(JURI::base().'templates/braincode-grunge/slideshow/css/jd.gallery.css');
	
	$document->addScript(JURI::base().'templates/braincode-grunge/slideshow/script/jd.gallery.js');
	$document->addScript(JURI::base().'templates/braincode-grunge/slideshow/script/jd.gallery.set.js');
	$document->addSCriptDeclaration("
	function startGallery() {
				var myGallery = new gallery($('myGallerySet'), {
					timed: true,
					showArrows: true,
					showInfopane: false,
					showCarousel: false,
					embedLinks: false,
					delay: ".$delay."
				});
				document.gallery = myGallery;
			}
			window.onDomReady(startGallery);
			");
	
	$html='<div id="myGallerySet"><div id="gallery1" class="galleryElement">';

		foreach($slides as $slide){
		
			if(JFile::exists(JPATH_SITE.DS.'templates'.DS.'braincode-grunge'.DS.'slides'.DS.$slide)){
			$ext=JFile::getExt($slide);
				if(($ext=='jpg'||$ext=='jpeg'||$ext=='png'||$ext=='gif')){
					
				$html.='<div class="imageElement">
							<img src="'.JURI::base().'templates/braincode-grunge/slides/'.$slide.'" class="full" />
						</div>';
				}
			}
			
		}
		
	$html.='</div></div>';	
	
	}else if(!empty($slides)){
	jimport('joomla.filesystem.file');
		if(JFile::exists(JPATH_SITE.DS.'templates'.DS.'braincode-grunge'.DS.'slides'.DS.$slides)){
			$ext=JFile::getExt($slides);
				if(($ext=='jpg'||$ext=='jpeg'||$ext=='png'||$ext=='gif')){
					
				$html.='<img src="'.JURI::base().'templates/braincode-grunge/slides/'.$slides.'" alt=""/>';
				
				}
			}
	
	}
	
		return $html;
	}

}
?>
